
clear all
set more off, perm
capture log close
set maxvar 32767

	
**# cognitive
cd "C:\Users\hp\Dropbox\ziyan\Pair Point Estimates\Figures\plots_updated\c" // change location

use c_add, clear
// replace var_ub_ = add_pe + 1.96*var_sd_
// replace var_lb_ = add_pe - 1.96*var_sd_

// replace var1 = subinstr(var1, "Level ", "", .)
// destring var1, replace
// rename level levelc2 
*kbar
preserve 
keep if var == "Kbar"
label var var_ub_ "95% CI"
label var add_pe "Minimum Skill Requirement"
twoway scatter add_pe level, sort msize(medium) ||  rcap var_ub_ var_lb_ level, sort lcolor(gs10) lwidth(medium) ///
	xlabel(1(1)13, labsize(small)) xmtick(, labsize(small)) ///
	xtitle(Difficulty Level, size(small)) ytitle(Kbar, size(small)) ylabel(,labsize(small)) ///
	title("Minimum Latent Cognitive Skills Requirement by Level", size(medium)) subtitle(Additive Model w/ Scale Invariance, size(small)) legend(order(1 2 "95% CI") row(1) size(small) nobox fcolor() region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
		note("Note: The confidence interval is based on 1,000 iteration bootstrap.", size(small) span)   ///
graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
	saving("add_kbar", replace)
	graph export "add_kbar.pdf", replace
restore


preserve 
keep if var != "Kbar" & var != "Delta"
label var var_ub_ "95% CI"
label var add_pe "{&sigma}{sup:2}({&epsilon},l)"
// foreach i in mul_pe var_lb_ var_ub_{
// 	replace `i' = ln(`i')
// }
replace var_lb_ = . if add_pe > 30
replace var_ub_ = . if add_pe > 30
replace add_pe = . if add_pe > 30

twoway scatter add_pe level, sort lwidth(medium) msize(medium) cmissing(n) || rcap var_ub_ var_lb_ level, sort lcolor(gs10) lwidth(medium) cmissing(n)  ///
	xlabel(2(1)12, labsize(small)) xmtick(, labsize(small)) ///
	xtitle(Difficulty Level, size(small)) ytitle("{&sigma}{sup:2}({&epsilon},l)", size(small)) ylabel(,labsize(small)) ///
	title("Variances of Task Shocks ({&sigma}{sup:2}({&epsilon},l)) by Level (Cognitive)", size(medium)) subtitle(Additive Model w/ Scale Invariance, size(small)) legend(order(1 "{&sigma}{sup:2}({&epsilon},l)" 2 "95% CI") row(1) size(small) nobox fcolor() region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
	note("Note: The confidence interval is based on 1,000 iteration bootstrap." "The variances with values over 30 are dropped in the figure to better visualize the estimates" "and their confidence intervals are not shown." "Variances at level 1 and 13 are normalized to one", size(small) span)   ///
	graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
	saving("add_sigma_30", replace)
	graph export "add_sigma_30.pdf", replace	
restore	
	
	
**log version
preserve 
keep if var != "Kbar" & var != "Delta"
label var var_ub_ "95% CI"
label var add_pe "{&sigma}{sup:2}({&epsilon},l)"
foreach i in add_pe var_lb_ var_ub_{
	replace `i' = ln(`i')
}
// replace var_lb_ = . if mul_pe > 30
// replace var_ub_ = . if mul_pe > 30
// replace mul_pe = . if mul_pe > 30

twoway scatter add_pe level, sort lwidth(medium) msize(medium) cmissing(n) || rcap var_ub_ var_lb_ level, sort lcolor(gs10) lwidth(medium) cmissing(n)  ///
	xlabel(2(1)12, labsize(small)) xmtick(, labsize(small)) ///
	xtitle(Difficulty Level, size(small)) ytitle("{&sigma}{sup:2}({&epsilon},l)", size(small)) ylabel(,labsize(small)) ///
	xtitle(Difficulty Level, size(small)) ytitle("log({&sigma}{sup:2}({&epsilon},l))", size(small)) ylabel(,labsize(small)) ///
	title("Log of Variances of Task Shocks ({&sigma}{sup:2}({&epsilon},l)) by Level (Cognitive)", size(medium)) subtitle(Additive Model w/ Scale Invariance, size(small)) legend(order(1 "{&sigma}{sup:2}({&epsilon},l)" 2 "95% CI") row(1) size(small) nobox fcolor() region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
	note("Note: The confidence interval is based on 1,000 iteration bootstrap." "Log values are shown in the figure to better visualize values of all levels." "Variances at Level 1 and 13 variances normalized to one.", size(small) span)   ///
	graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
	saving("add_sigma", replace)
	graph export "add_sigma.pdf", replace	
restore	
	
preserve 
keep if var == "Delta"
label var var_ub_ "95% CI"
label var add_pe "{&Delta}{sub:k}"
twoway scatter add_pe level, sort lwidth(medium) msize(medium) ||  rcap var_ub_ var_lb_ level, sort lcolor(gs10) lwidth(medium)  ///
	xlabel(2 5 6 7 8 10 11 12, labsize(small)) xmtick(, labsize(small)) ///
	xtitle(Difficulty Level, size(small)) ytitle("{&Delta}{sub:k}", size(small)) ylabel(,labsize(small)) ///
	title("Learning Task Component ({&Delta}{sub:k}) by Level (Cognitive)", size(medium)) subtitle(Additive Model w/ Scale Invariance, size(small)) legend(order(1 2 "95% CI") row(1) size(small) nobox fcolor() region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
	note("Note: The confidence interval is based on 1,000 iteration bootstrap." "Values at Levels 1, 3, 4, 9 and 13 are normalized to 1.", size(small) span)   ///
graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
	saving("add_Delta", replace)
	graph export "add_Delta.pdf", replace	
restore	



**# cog_add_wo


	
use "c_add_wo_si", clear

capture destring var_lb_ var_ub_ var_sd_ , replace force
// replace var_ub_ = add_pe + 1.96*var_sd_
// replace var_lb_ = add_pe - 1.96*var_sd_

preserve 
keep if var == "Kbar"
label var var_ub_ "95% CI"
label var add_pe "Minimum Skill Requirement"
twoway scatter add_pe level, sort msize(medium) ||  rcap var_ub_ var_lb_ level, sort lcolor(gs10) lwidth(medium) ///
	xlabel(1(1)13, labsize(small)) xmtick(, labsize(small)) ///
	xtitle(Difficulty Level, size(small)) ytitle(Kbar, size(small)) ylabel(,labsize(small)) ///
	title("Minimum Latent Cognitive Skills Requirement by Level", size(medium)) subtitle(Additive Model w/ Scale Invariance, size(small)) legend(order(1 2 "95% CI") row(1) size(small) nobox fcolor() region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
		note("Note: The confidence interval is based on 1,000 iteration bootstrap.", size(small) span)   ///
graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
	saving("add_kbar", replace)
	graph export "add_kbar_wo.pdf", replace
restore


preserve 
keep if var != "Kbar" & var != "Delta"& var != "Beta1"
label var var_ub_ "95% CI"
label var add_pe "{&sigma}{sup:2}({&epsilon},l)"
// foreach i in mul_pe var_lb_ var_ub_{
// 	replace `i' = ln(`i')
// }
replace var_lb_ = . if add_pe > 30
replace var_ub_ = . if add_pe > 30
replace add_pe = . if add_pe > 30

twoway scatter add_pe level, sort lwidth(medium) msize(medium) cmissing(n) || rcap var_ub_ var_lb_ level, sort lcolor(gs10) lwidth(medium) cmissing(n)  ///
	xlabel(2(1)12, labsize(small)) xmtick(, labsize(small)) ///
	xtitle(Difficulty Level, size(small)) ytitle("{&sigma}{sup:2}({&epsilon},l)", size(small)) ylabel(,labsize(small)) ///
	title("Variances of Task Shocks ({&sigma}{sup:2}({&epsilon},l)) by Level (Cognitive)", size(medium)) subtitle(Additive Model w/ Scale Invariance, size(small)) legend(order(1 "{&sigma}{sup:2}({&epsilon},l)" 2 "95% CI") row(1) size(small) nobox fcolor() region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
	note("Note: The confidence interval is based on 1,000 iteration bootstrap." "The variances with values over 30 are dropped in the figure to better visualize the estimates" "and their confidence intervals are not shown." "Variances at level 1 and 13 are normalized to one", size(small) span)   ///
	graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
	saving("add_sigma_30_wo", replace)
	graph export "add_sigma_30_wo.pdf", replace	
restore	
	
	
**log version
preserve 
keep if var != "Kbar" & var != "Delta"& var != "Beta1"
label var var_ub_ "95% CI"
label var add_pe "{&sigma}{sup:2}({&epsilon},l)"
foreach i in add_pe var_lb_ var_ub_{
	replace `i' = ln(`i')
}

twoway scatter add_pe level, sort lwidth(medium) msize(medium) cmissing(n) || rcap var_ub_ var_lb_ level, sort lcolor(gs10) lwidth(medium) cmissing(n)  ///
	xlabel(2(1)12, labsize(small)) xmtick(, labsize(small)) ///
	xtitle(Difficulty Level, size(small)) ytitle("{&sigma}{sup:2}({&epsilon},l)", size(small)) ylabel(,labsize(small)) ///
	xtitle(Difficulty Level, size(small)) ytitle("log({&sigma}{sup:2}({&epsilon},l))", size(small)) ylabel(,labsize(small)) ///
	title("Log of Variances of Task Shocks ({&sigma}{sup:2}({&epsilon},l)) by Level (Cognitive)", size(medium)) subtitle(Additive Model w/ Scale Invariance, size(small)) legend(order(1 "{&sigma}{sup:2}({&epsilon},l)" 2 "95% CI") row(1) size(small) nobox fcolor() region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
	note("Note: The confidence interval is based on 1,000 iteration bootstrap." "Log values are shown in the figure to better visualize values of all levels." "Variances at Level 1 and 13 variances normalized to one.", size(small) span)   ///
	graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
	saving("add_sigma_wo", replace)
	graph export "add_sigma_wo.pdf", replace	
restore	
	
preserve 
keep if var == "Delta"
label var var_ub_ "95% CI"
label var add_pe "{&Delta}{sub:k}"
twoway scatter add_pe level, sort lwidth(medium) msize(medium) ||  rcap var_ub_ var_lb_ level, sort lcolor(gs10) lwidth(medium)  ///
	xlabel(2 5 6 7 8 10 11 12, labsize(small)) xmtick(, labsize(small)) ///
	xtitle(Difficulty Level, size(small)) ytitle("{&Delta}{sub:k}", size(small)) ylabel(,labsize(small)) ///
	title("Learning Task Component ({&Delta}{sub:k}) by Level (Cognitive)", size(medium)) subtitle(Additive Model w/ Scale Invariance, size(small)) legend(order(1 2 "95% CI") row(1) size(small) nobox fcolor() region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
	note("Note: The confidence interval is based on 1,000 iteration bootstrap." "Values at Levels 1, 3, 4, 9 and 13 are normalized to 1.", size(small) span)   ///
graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
	saving("add_Delta_wo", replace)
	graph export "add_Delta_wo.pdf", replace	
restore	



preserve 
keep if var == "Beta1"
label var var_ub_ "95% CI"
label var add_pe "{&beta}{sub:1}"
twoway connected add_pe level, sort lwidth(medium) msize(medium) || line var_ub_ level, sort lcolor(gs11) lpattern(dash) lwidth(medium) || line var_lb_ level, sort lcolor(gs11) lpattern(dash) lwidth(medium)   ///
	xlabel(1(1)13, labsize(small)) xmtick(, labsize(small)) yline(1, lcolor(khaki) lwidth(medium))  ///
	xtitle(Difficulty Level, size(small)) ytitle("{&beta}{sub:1}", size(small)) ylabel(,labsize(small)) ///
	title("Transformation Function Slope ({&beta}{sub:1}) by Level (Cognitive)", size(large)) subtitle(Additive Model w/o Scale Invariance, size(medium)) legend(order(1 2) row(1) size(small) nobox fcolor() region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
	note("Note: The confidence interval is based on 1,000 iteration bootstrap.", size(small) span)   ///
	graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
	saving("add_beta1", replace)
	graph export "add_beta1.pdf", replace
restore	

	

**mul
**# cog_mul

use "c_mul", clear
// replace var_ub_ = mul_pe + 1.96*var_sd_
// replace var_lb_ = mul_pe - 1.96*var_sd_

// replace var1 = subinstr(var1, "Level ", "", .)
// destring var1, replace
// rename level levelc2 
*kbar
preserve 
keep if var == "Kbar"
drop if level == 13
label var var_ub_ "95% CI"
label var mul_pe "Minimum Skill Requirement"
twoway scatter mul_pe level, sort lwidth(medium) msize(medium) || rcap var_ub_ var_lb_ level, sort lcolor(gs10) lwidth(medium)  ///
	xlabel(2(1)12, labsize(small)) xmtick(, labsize(small)) ///
	xtitle(Difficulty Level, size(small)) ytitle(Kbar, size(small)) ylabel(,labsize(small)) ///
	title("Minimum Latent Cognitive Skills Requirement by Level", size(medium)) subtitle(Multiplicative Model with Skill Invariance, size(small)) legend(order(1 2 "95% CI") row(1) size(small) nobox fcolor() region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
	note("Note: The confidence interval is based on 1,000 iteration bootstrap." "The Value at Level 13 is dropped in this figure due to the extreme variance in the estimation." "The value at Level 1 normalized to one.", size(small) span)   ///
	graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
	saving("mul_kbar", replace)
	graph export "mul_kbar.pdf", replace
restore


preserve 
keep if var != "Kbar" & var != "Delta"
label var var_ub_ "95% CI"
label var mul_pe "{&sigma}{sup:2}({&epsilon},l)"
// foreach i in mul_pe var_lb_ var_ub_{
// 	replace `i' = ln(`i')
// }
replace var_lb_ = . if mul_pe > 30
replace var_ub_ = . if mul_pe > 30
replace mul_pe = . if mul_pe > 30

twoway scatter mul_pe level, sort lwidth(medium) msize(medium) cmissing(n) || rcap var_ub_ var_lb_ level, sort lcolor(gs10) lwidth(medium) cmissing(n)  ///
	xlabel(2(1)12, labsize(small)) xmtick(, labsize(small)) ///
	xtitle(Difficulty Level, size(small)) ytitle("{&sigma}{sup:2}({&epsilon},l)", size(small)) ylabel(,labsize(small)) ///
	title("Variances of Task Shocks ({&sigma}{sup:2}({&epsilon},l)) by Level (Cognitive)", size(medium)) subtitle(Multiplicative Model with Skill Invariance, size(small)) legend(order(1 "{&sigma}{sup:2}({&epsilon},l)" 2 "95% CI") row(1) size(small) nobox fcolor() region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
	note("Note: The confidence interval is based on 1,000 iteration bootstrap." "The variances with values over 30 are dropped in the figure to better visualize the estimates" "and their confidence intervals are not shown." "Variances at level 1 and 13 are normalized to one.", size(small) span)   ///
	graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
	saving("mul_sigma", replace)
	graph export "mul_sigma.pdf", replace	
restore	
	
	
**log version
preserve 
keep if var != "Kbar" & var != "Delta"
label var var_ub_ "95% CI"
label var mul_pe "{&sigma}{sup:2}({&epsilon},l)"
foreach i in mul_pe var_lb_ var_ub_{
	replace `i' = ln(`i')
}
// replace var_lb_ = . if mul_pe > 30
// replace var_ub_ = . if mul_pe > 30
// replace mul_pe = . if mul_pe > 30

twoway scatter mul_pe level, sort lwidth(medium) msize(medium) cmissing(n) || rcap var_ub_ var_lb_ level, sort lcolor(gs10) lwidth(medium) cmissing(n)  ///
	xlabel(2(1)12, labsize(small)) xmtick(, labsize(small)) ///
	xtitle(Difficulty Level, size(small)) ytitle("{&sigma}{sup:2}({&epsilon},l)", size(small)) ylabel(,labsize(small)) ///
	xtitle(Difficulty Level, size(small)) ytitle("log({&sigma}{sup:2}({&epsilon},l))", size(small)) ylabel(,labsize(small)) ///
	title("Log of Variances of Task Shocks ({&sigma}{sup:2}({&epsilon},l)) by Level (Cognitive)", size(medium)) subtitle(Multiplicative Model with Skill Invariance, size(small)) legend(order(1 "{&sigma}{sup:2}({&epsilon},l)" 2 "95% CI") row(1) size(small) nobox fcolor() region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
	note("Note: The confidence interval is based on 1,000 iteration bootstrap." "Log values are shown in the figure to better visualize values of all levels." "Variances at Level 1 and 13 are normalized to one.", size(small) span)   ///
	graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
	saving("mul_logsigma", replace)
	graph export "mul_logsigma.pdf", replace	
restore	
	
//	
preserve 
keep if var == "Delta"
label var var_ub_ "95% CI"
label var mul_pe "{&Delta}{sub:k}"
twoway scatter mul_pe level, sort lwidth(medium) msize(medium) || rcap var_ub_ var_lb_ level, sort lcolor(gs10) lwidth(medium)  ///
 	xlabel(2 5 6 7 8 10 11 12, labsize(small)) xmtick(, labsize(small)) ///
 	xtitle(Difficulty Level, size(small)) ytitle("{&Delta}{sub:k}", size(small)) ylabel(,labsize(small)) ///
 	title("Learning Task Component ({&Delta}{sub:k}) by Level (Cognitive)", size(medium)) subtitle(Multiplicative Model with Skill Invariance, size(small)) legend(order(1 2 "95% CI") row(1) size(small) nobox fcolor() region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
 	note("Note: The confidence interval is based on 1,000 iteration bootstrap." "Levels 1, 3, 4, 9 and 13 normalized to 1.", size(small) span)   ///
 	graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
 	saving("mul_Delta", replace)
 	graph export "mul_Delta.pdf", replace	
restore	

**# cog w/o invariance

use "c_mul_wo_si", clear
capture destring var_lb_ var_ub_, replace force

// replace var_ub_ = mul_pe + 1.96*var_sd_
// replace var_lb_ = mul_pe - 1.96*var_sd_

// replace var1 = subinstr(var1, "Level ", "", .)
// destring var1, replace
// rename level levelc2 
*kbar
preserve 
keep if var == "Kbar"
drop if level == 13
label var var_ub_ "95% CI"
label var mul_pe "Minimum Skill Requirement"
twoway scatter mul_pe level, sort lwidth(medium) msize(medium) || rcap var_ub_ var_lb_ level, sort lcolor(gs10) lwidth(medium)  ///
	xlabel(2(1)12, labsize(small)) xmtick(, labsize(small)) ///
	xtitle(Difficulty Level, size(small)) ytitle(Kbar, size(small)) ylabel(,labsize(small)) ///
	title("Minimum Latent Cognitive Skills Requirement by Level", size(medium)) subtitle(Multiplicative Model without Skill Invariance, size(small)) legend(order(1 2 "95% CI") row(1) size(small) nobox fcolor() region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
	note("Note: The confidence interval is based on 1,000 iteration bootstrap." "The Value at Level 13 is dropped in this figure due to the extreme variance in the estimation." "The value at Level 1 normalized to one.", size(small) span)   ///
	graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
	saving("mul_kbar_wo", replace)
	graph export "mul_kbar_wo.pdf", replace
restore


preserve 
keep if var != "Kbar" & var != "Delta"& var != "Beta1"
label var var_ub_ "95% CI"
label var mul_pe "{&sigma}{sup:2}({&epsilon},l)"
// foreach i in mul_pe var_lb_ var_ub_{
// 	replace `i' = ln(`i')
// }
replace var_lb_ = . if mul_pe > 30
replace var_ub_ = . if mul_pe > 30
replace mul_pe = . if mul_pe > 30

twoway scatter mul_pe level, sort lwidth(medium) msize(medium) cmissing(n) || rcap var_ub_ var_lb_ level, sort lcolor(gs10) lwidth(medium) cmissing(n)  ///
	xlabel(2(1)12, labsize(small)) xmtick(, labsize(small)) ///
	xtitle(Difficulty Level, size(small)) ytitle("{&sigma}{sup:2}({&epsilon},l)", size(small)) ylabel(,labsize(small)) ///
	title("Variances of Task Shocks ({&sigma}{sup:2}({&epsilon},l)) by Level (Cognitive)", size(medium)) subtitle(Multiplicative Model without Skill Invariance, size(small)) legend(order(1 "{&sigma}{sup:2}({&epsilon},l)" 2 "95% CI") row(1) size(small) nobox fcolor() region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
	note("Note: The confidence interval is based on 1,000 iteration bootstrap." "The variances with values over 30 are dropped in the figure to better visualize the estimates" "and their confidence intervals are not shown." "Variances at level 1 and 13 are normalized to one.", size(small) span)   ///
	graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
	saving("mul_sigma_wo", replace)
	graph export "mul_sigma_wo.pdf", replace	
restore	
	
	
**log version
preserve 
keep if var != "Kbar" & var != "Delta"& var != "Beta1"
label var var_ub_ "95% CI"
label var mul_pe "{&sigma}{sup:2}({&epsilon},l)"
foreach i in mul_pe var_lb_ var_ub_{
	replace `i' = ln(`i')
}
// replace var_lb_ = . if mul_pe > 30
// replace var_ub_ = . if mul_pe > 30
// replace mul_pe = . if mul_pe > 30

twoway scatter mul_pe level, sort lwidth(medium) msize(medium) cmissing(n) || rcap var_ub_ var_lb_ level, sort lcolor(gs10) lwidth(medium) cmissing(n)  ///
	xlabel(2(1)12, labsize(small)) xmtick(, labsize(small)) ///
	xtitle(Difficulty Level, size(small)) ytitle("{&sigma}{sup:2}({&epsilon},l)", size(small)) ylabel(,labsize(small)) ///
	xtitle(Difficulty Level, size(small)) ytitle("log({&sigma}{sup:2}({&epsilon},l))", size(small)) ylabel(,labsize(small)) ///
	title("Log of Variances of Task Shocks ({&sigma}{sup:2}({&epsilon},l)) by Level (Cognitive)", size(medium)) subtitle(Multiplicative Model without Skill Invariance, size(small)) legend(order(1 "{&sigma}{sup:2}({&epsilon},l)" 2 "95% CI") row(1) size(small) nobox fcolor() region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
	note("Note: The confidence interval is based on 1,000 iteration bootstrap." "Log values are shown in the figure to better visualize values of all levels." "Variances at Level 1 and 13 are normalized to one.", size(small) span)   ///
	graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
	saving("mul_logsigma_wo", replace)
	graph export "mul_logsigma_wo.pdf", replace	
restore	

preserve 
keep if var == "Delta"
label var var_ub_ "95% CI"
label var mul_pe "{&Delta}{sub:k}"
twoway scatter mul_pe level, sort lwidth(medium) msize(medium) || rcap var_ub_ var_lb_ level, sort lcolor(gs10) lwidth(medium)  ///
 	xlabel(2 5 6 7 8 10 11 12, labsize(small)) xmtick(, labsize(small)) ///
 	xtitle(Difficulty Level, size(small)) ytitle("{&Delta}{sub:k}", size(small)) ylabel(,labsize(small)) ///
 	title("Learning Task Component ({&Delta}{sub:k}) by Level (Cognitive)", size(medium)) subtitle(Multiplicative Model without Skill Invariance, size(small)) legend(order(1 2 "95% CI") row(1) size(small) nobox fcolor() region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
 	note("Note: The confidence interval is based on 1,000 iteration bootstrap." "Levels 1, 3, 4, 9 and 13 normalized to 1.", size(small) span)   ///
 	graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
 	saving("mul_Delta_wo", replace)
 	graph export "mul_Delta_wo.pdf", replace	
restore	


preserve 
 replace var_ub_ = mul_pe + 1.96*var_sd_
 replace var_lb_ = mul_pe - 1.96*var_sd_

keep if var == "Beta1"
label var var_ub_ "95% CI"
label var mul_pe "{&gamma}{sub:1,l}"
twoway connected mul_pe level, sort lwidth(medium) msize(medium) || line var_ub_ level, sort lcolor(gs11) lpattern(dash) lwidth(medium) || line var_lb_ level, sort lcolor(gs11) lpattern(dash) lwidth(medium)   ///
	xlabel(2(1)13, labsize(small)) xmtick(, labsize(small)) yline(1, lcolor(khaki) lwidth(medium)) ///
	xtitle(Difficulty Level, size(small)) ytitle("{&gamma}{sub:1,l}", size(small)) ylabel(,labsize(small)) ///
	title("Transformation Function Slope ({&gamma}{sub:1,l}) by Level (Cognitive)", size(large)) subtitle(Multiplicative Model without Skill Invariance, size(medium)) legend(order(1 2) row(1) size(small) nobox fcolor() region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
	note("Note: The confidence interval is based on standard error.", size(small) span)   ///
	graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
	saving("mul_beta1_sd_wo", replace)
	graph export "mul_beta1_sd_wo.pdf", replace
restore	

	
**# cog_deltaeta

use eta_delta_c_add, clear
label var m_eta_1_ "Fast"
label var m_eta_2_ "Normal"
label var m_eta_3_ "Slow"
label var ul_1_ "95% CI"
// twoway line m_eta_1_ level, sort lwidth(medium) || line ul_1_ level, sort lcolor(gs15) lpattern(dash) lwidth(medium) || line ll_1_ level, sort lcolor(gs15) lpattern(dash) lwidth(medium) || connected m_eta_2_ level, sort msize(medium) lwidth(medium) || line ul_2_ level, sort lcolor(gs15) lpattern(dash) lwidth(medium) || line ll_2_ level, sort lcolor(gs15) lpattern(dash) lwidth(medium) || line m_eta_3_ level, sort lpattern(longdash_shortdash) lwidth(medium) || line ul_3_ level, sort lcolor(gs15) lpattern(dash) lwidth(medium) || line ll_3_ level, sort lcolor(gs15) lpattern(dash) lwidth(medium) ///
twoway connected m_eta_1_ level, sort lwidth(medthick) msize(medium) mc(navy) lcolor(navy) lpattern(dash)|| rcap ul_1_ ll_1_ level, sort lcolor(gs12) lwidth(medthick) || connected m_eta_2_ level, sort msize(medium) m(S) mc(olive) lcolor(olive)  lpattern(dash) || rcap ul_2_ ll_2_ level, sort lcolor(gs12) lwidth(medthick) || connected m_eta_3_ level, sort msize(medium) m(T) mc(orange) lcolor(orange)  lpattern(dash) || rcap ul_3_ ll_3_ level, sort lcolor(gs12) lwidth(medthick)  ///
	xlabel(2 5 6 7 8 10 11 12, labsize(small)) xmtick(, labsize(small)) ///
	xtitle(Difficulty Level, size(small)) ytitle({&delta}(l)E({&eta}), size(small)) ylabel(,labsize(small)) ///
	title(Learning Component ({&delta}(l)E({&eta})) by Difficulty Level (Cognitive), size(med)) subtitle(by Ability Group, size(medsmall)) legend(order(1 3 5 2 "95% CI") row(1) size(vsmall) nobox fcolor() region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
	note("1. Fast group: the child can pass the first task at over 80% of the difficulty levels, and the average pass rate at that level is greater than 80%." "Normal group: the child doesn't pass the first task, and the pass rate is greater than 50%; or the child passes the first task, and the pass rate is" "between 50% and 80%. Slow group: the average pass rate is less than 50%.    2. 95% confidence intervals are shown for three groups." "3. The values of {&Delta} for level 1, 3, 4, 9, and 13 are normalized to one.", size(vsmall) span) ///
	graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
	saving("add_deltaeta", replace)
	graph export "add_deltaeta.pdf", replace



	
use eta_delta_c_mul_vec, clear
label var m_eta_1_ "Fast"
label var m_eta_2_ "Normal"
label var m_eta_3_ "Slow"
label var ul_1_ "95% CI"
// twoway line m_eta_1_ level, sort lwidth(medium) || line ul_1_ level, sort lcolor(gs15) lpattern(dash) lwidth(medium) || line ll_1_ level, sort lcolor(gs15) lpattern(dash) lwidth(medium) || connected m_eta_2_ level, sort msize(medium) lwidth(medium) || line ul_2_ level, sort lcolor(gs15) lpattern(dash) lwidth(medium) || line ll_2_ level, sort lcolor(gs15) lpattern(dash) lwidth(medium) || line m_eta_3_ level, sort lpattern(longdash_shortdash) lwidth(medium) || line ul_3_ level, sort lcolor(gs15) lpattern(dash) lwidth(medium) || line ll_3_ level, sort lcolor(gs15) lpattern(dash) lwidth(medium) ///

// twoway scatter m_eta_1_ level, sort lwidth(medthick) msize(medium) mc(navy) lcolor(navy) lpattern(dash)|| rcap ul_1_ ll_1_ level, sort lcolor(gs12) lwidth(medthick) || scatter m_eta_2_ level, sort msize(medium) m(S) mc(olive) lcolor(olive)  lpattern(dash) || rcap ul_2_ ll_2_ level, sort lcolor(gs12) lwidth(medthick) || scatter m_eta_3_ level, sort msize(medium) m(T) mc(orange) lcolor(orange)  lpattern(dash) || rcap ul_3_ ll_3_ level, sort lcolor(gs12) lwidth(medthick)  ///
twoway connected m_eta_1_ level, sort lwidth(medthick) msize(medium) mc(navy) lcolor(navy) lpattern(dash)|| rcap ul_1_ ll_1_ level, sort lcolor(gs12) lwidth(medthick) || connected m_eta_2_ level, sort msize(medium) m(S) mc(olive) lcolor(olive)  lpattern(dash) || rcap ul_2_ ll_2_ level, sort lcolor(gs12) lwidth(medthick) || connected m_eta_3_ level, sort msize(medium) m(T) mc(orange) lcolor(orange)  lpattern(dash) || rcap ul_3_ ll_3_ level, sort lcolor(gs12) lwidth(medthick)  ///	
	xlabel(2 5 6 7 8 10 11 12, labsize(small)) xmtick(, labsize(small)) ///
	xtitle(Difficulty Level, size(small)) ytitle({&delta}(l)E({&eta}), size(small)) ylabel(,labsize(small)) ///
	title(Learning Component ({&delta}(l)E({&eta})) by Difficulty Level (Cognitive), size(med)) subtitle(by Ability Group, size(medsmall)) legend(order(1 3 5 2 "95% CI") row(1) size(vsmall) nobox fcolor() region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
	note("1. Fast group: the child can pass the first task at over 80% of the difficulty levels, and the average pass rate at that level is greater than 80%." "Normal group: the child doesn't pass the first task, and the pass rate is greater than 50%; or the child passes the first task, and the pass rate is" "between 50% and 80%. Slow group: the average pass rate is less than 50%.    2. 95% confidence intervals are shown for three groups." "3. The values of {&Delta} for level 1, 3, 4, 9, and 13 are normalized to one.", size(vsmall) span) ///
	graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
	saving("mul_deltaeta", replace)
	graph export "mul_deltaeta.pdf", replace


/*


graph combine "add_sigma_30" "mul_sigma_30", rows(1) title("Variances of Task Shocks ({&sigma}{sup:2}({&epsilon},l)) by Level (Fine Motor)", size(medlarge)) ///
	xsize(11) ysize(4) ycommon   ///
	graphregion(margin(small) fcolor(white) ifcolor(white)) plotregion(margin(small) fcolor(white))  ///
	saving("add_mul_sigma_30", replace)
	graph export "add_mul_sigma_30.pdf", replace
	

	
graph combine "add_beta0_no12" "mul_beta0", 	rows(1) title("Transformation Function {&omega}{sub:l} (Cognitive)", size(medlarge)) ///
	subtitle(Additive and Multiplicative Model Intercept ({&beta}{sub:0,l}), size(medium)) xsize(12) ysize(4) ycommon  ///
	note("Note: The confidence interval is based on 1,000 iteration bootstrap." "Level 12 of Additive Model is dropped because the value is bigger than 10.", size(small) span)   ///
	graphregion(margin(small) fcolor(white) ifcolor(white)) plotregion(margin(small) fcolor(white))  ///
	saving("add_mul_beta0", replace)
	graph export "add_mul_beta0.pdf", replace
*/


**# cog_mul_vesc
use "c_mul_vesc", clear
// replace var_ub_ = mul_pe + 1.96*var_sd_
// replace var_lb_ = mul_pe - 1.96*var_sd_

// replace var1 = subinstr(var1, "Level ", "", .)
// destring var1, replace
// rename level levelc2 
*kbar
preserve 
keep if var == "Kbar"
drop if level == 13
label var var_ub_ve "95% CI of vector model"
label var var_ub_sc "95% CI of scalar model"
label var mul_pe_ve "Minimum Skill Requirement of vector model"
label var mul_pe_sc "Minimum Skill Requirement of scalar model"
twoway (scatter mul_pe_ve level, sort lwidth(medthick) msize(small)) ///
       (scatter mul_pe_sc level, sort lcolor(red) lwidth(medthick) msize(small)) ///
       (rcap var_ub_ve var_lb_ve level, sort lcolor(green) lwidth(tiny)) ///
       (rcap var_ub_sc var_lb_sc level, sort lcolor(red) lwidth(tiny) lpattern(dash)), ///
       xlabel(2(1)12, labsize(small)) xmtick(, labsize(small)) ///
       xtitle(Difficulty Level, size(small)) ytitle(Kbar, size(small)) ylabel(, labsize(small)) ///
       title("Minimum Latent Cognitive Skills Requirement by Level", size(medium)) ///
       subtitle(Multiplicative Model with Skill Invariance, size(small)) ///
       legend(order(1 "Minimum Skill Requirement - vector" 2 "Minimum Skill Requirement - scalar" 3 "95% CI of vector model" 4 "95% CI of scalar model") row(2) size(small) nobox fcolor() ///
       region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
       note("Note: The confidence interval is based on 1,000 iteration bootstrap." "The Value at Level 13 is dropped in this figure due to the extreme variance in the estimation." "The value at Level 1 normalized to one.", size(small) span)   ///
       graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
       ylabel(, labsize(medium))
graph save "mul_kbar_vesc", replace
graph export "mul_kbar_vesc.pdf", replace
restore	


preserve 
keep if var == "Kbar"
drop if level == 13
label var var_ub_ve "95% CI of vector model"
label var var_ub_sc "95% CI of scalar model"
label var mul_pe_ve "Minimum Skill Requirement of vector model"
label var mul_pe_sc "Minimum Skill Requirement of scalar model"
foreach i in mul_pe_ve var_lb_ve var_ub_ve{
	replace `i' = ln(`i')
}
foreach i in mul_pe_sc var_lb_sc var_ub_sc{
	replace `i' = ln(`i')
}
twoway (scatter mul_pe_ve level, sort lwidth(medthick) msize(small)) ///
       (scatter mul_pe_sc level, sort lcolor(red) lwidth(medthick) msize(small)) ///
       (rcap var_ub_ve var_lb_ve level, sort lcolor(green) lwidth(tiny)) ///
       (rcap var_ub_sc var_lb_sc level, sort lcolor(red) lwidth(tiny) lpattern(dash)), ///
       xlabel(2(1)12, labsize(small)) xmtick(, labsize(small)) ///
       xtitle(Difficulty Level, size(small)) ytitle(Kbar, size(small)) ylabel(, labsize(small)) ///
       title("Log of Minimum Latent Cognitive Skills Requirement by Level", size(medium)) ///
       subtitle(Multiplicative Model with Skill Invariance, size(small)) ///
       legend(order(1 "Minimum Skill Requirement - vector" 2 "Minimum Skill Requirement - scalar" 3 "95% CI of vector model" 4 "95% CI of scalar model") row(2) size(small) nobox fcolor() ///
       region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
       note("Note: The confidence interval is based on 1,000 iteration bootstrap." "The Value at Level 13 is dropped in this figure due to the extreme variance in the estimation." "The value at Level 1 normalized to one.", size(small) span)   ///
       graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
       ylabel(, labsize(medium))
graph save "mul_logkbar_vesc", replace
graph export "mul_logkbar_vesc.pdf", replace
restore


preserve 
keep if var != "Kbar" & var != "Delta"
label var var_ub_ve "95% CI of vector model"
label var var_ub_sc "95% CI of scalar model"
label var mul_pe_ve "σ²(ε,l) of vector model"
label var mul_pe_sc "σ²(ε,l) of scalar model"
// foreach i in mul_pe var_lb_ var_ub_{
// 	replace `i' = ln(`i')
// }
replace var_lb_ve = . if mul_pe_ve > 30
replace var_ub_ve = . if mul_pe_ve > 30
replace mul_pe_ve = . if mul_pe_ve > 30
replace var_lb_sc = . if mul_pe_sc > 30
replace var_ub_sc = . if mul_pe_sc > 30
replace mul_pe_sc = . if mul_pe_sc > 30

twoway (scatter mul_pe_ve level, sort lwidth(medthick) msize(small) cmissing(n)) ///
       (scatter mul_pe_sc level, sort lcolor(red) lwidth(medthick) msize(small) cmissing(n)) ///
       (rcap var_ub_ve var_lb_ve level, sort lcolor(green) lwidth(tiny) cmissing(n)) ///
       (rcap var_ub_sc var_lb_ve level, sort lcolor(red) lwidth(tiny) lpattern(dash) cmissing(n)), ///
	   xlabel(2(1)12, labsize(small)) xmtick(, labsize(small)) ///
       xtitle(Difficulty Level, size(small)) ytitle("σ²(ε,l)", size(small)) ylabel(, labsize(small)) ///
       title("Variances of Task Shocks (σ²(ε,l)) by Level (Cognitive)", size(medium)) ///
       subtitle(Multiplicative Model with Skill Invariance, size(small)) ///
       legend(order(1 "σ²(ε,l) of vector model" 2 "σ²(ε,l) of scalar model" 3 "95% CI of vector model" 4 "95% CI of scalar model") row(2) size(small) nobox fcolor() ///
	   region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
       note("Note: The confidence interval is based on 1,000 iteration bootstrap." "The variances with values over 30 are dropped in the figure to better visualize the estimates" "and their confidence intervals are not shown." "Variances at level 1 and 13 are normalized to one.", size(small) span)   ///
       graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
       ylabel(, labsize(medium))
       graph save "mul_sigma_vesc", replace
       graph export "mul_sigma_vesc.pdf", replace
restore	
		
	
**log version
preserve 
keep if var != "Kbar" & var != "Delta"
label var var_ub_ve "95% CI of vector model"
label var var_ub_sc "95% CI of scalar model"
label var mul_pe_ve "σ²(ε,l) of vector model"
label var mul_pe_sc "σ²(ε,l) of scalar model"
foreach i in mul_pe_ve var_lb_ve var_ub_ve{
	replace `i' = ln(`i')
}
foreach i in mul_pe_sc var_lb_sc var_ub_sc{
	replace `i' = ln(`i')
}
// replace var_lb_ = . if mul_pe > 30
// replace var_ub_ = . if mul_pe > 30
// replace mul_pe = . if mul_pe > 30

twoway (scatter mul_pe_ve level, sort lwidth(medthick) msize(small) cmissing(n)) ///
       (scatter mul_pe_sc level, sort lcolor(red) lwidth(medthick) msize(small) cmissing(n)) ///
       (rcap var_ub_ve var_lb_ve level, sort lcolor(green) lwidth(tiny) cmissing(n)) ///
       (rcap var_ub_sc var_lb_sc level, sort lcolor(red) lwidth(tiny) lpattern(dash) cmissing(n)), ///
	   xlabel(2(1)12, labsize(small)) xmtick(, labsize(small)) ///
       xtitle(Difficulty Level, size(small)) ytitle("σ²(ε,l)", size(small)) ylabel(, labsize(small)) ///
	   xtitle(Difficulty Level, size(small)) ytitle("log(σ²(ε,l))", size(small)) ylabel(,labsize(small)) ///
       title("Log of Variances of Task Shocks (σ²(ε,l)) by Level (Cognitive)", size(medium)) ///
       subtitle(Multiplicative Model with Skill Invariance, size(small)) ///
       legend(order(1 "σ²(ε,l) of vector model" 2 "σ²(ε,l) of scalar model" 3 "95% CI of vector model" 4 "95% CI of scalar model") row(2) size(small) nobox fcolor() ///
       region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
       note("Note: The confidence interval is based on 1,000 iteration bootstrap." "Log values are shown in the figure to better visualize values of all levels." "Variances at Level 1 and 13 are normalized to one.", size(small) span)   ///
       graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
       ylabel(, labsize(medium))
	   graph save "mul_logsigma_vesc", replace
       graph export "mul_logsigma_vesc.pdf", replace
restore	


preserve 
keep if var == "Delta"
label var var_ub_ve "95% CI of vector model"
label var var_ub_sc "95% CI of scalar model"
label var mul_pe_ve "{&Delta}{sub:k} of vector model"
label var mul_pe_sc "{&Delta}{sub:k} of scalar model"
twoway (scatter mul_pe_ve level, sort lwidth(medthick) msize(small) cmissing(n)) ///
       (scatter mul_pe_sc level, sort lcolor(red) lwidth(medthick) msize(small) cmissing(n)) ///
       (rcap var_ub_ve var_lb_ve level, sort lcolor(green) lwidth(tiny) cmissing(n)) ///
       (rcap var_ub_sc var_lb_sc level, sort lcolor(red) lwidth(tiny) lpattern(dash) cmissing(n)), ///
	   xlabel(2 5 6 7 8 10 11 12, labsize(small)) xmtick(, labsize(small)) ///
       xtitle(Difficulty Level, size(small)) ytitle("{&Delta}{sub:k}", size(small)) ylabel(, labsize(small)) ///
       title("Variances of Task Shocks ({&Delta}{sub:k}) by Level (Cognitive)", size(medium)) ///
       subtitle(Multiplicative Model with Skill Invariance, size(small)) ///
       legend(order(1 "{&Delta}{sub:k} of vector model" 2 "{&Delta}{sub:k} of scalar model" 3 "95% CI of vector model" 4 "95% CI of scalar model") row(2) size(small) nobox fcolor() ///
	   region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
       note("Note: The confidence interval is based on 1,000 iteration bootstrap." "Levels 1, 3, 4, 9 and 13 normalized to 1.", size(small) span)   ///
       graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
 	   saving("mul_Delta_vesc", replace)
 	   graph export "mul_Delta_vesc.pdf", replace	
restore	


preserve 
keep if var == "Delta"
label var var_ub_ve "95% CI of vector model"
label var var_ub_sc "95% CI of scalar model"
label var mul_pe_ve "{&Delta}{sub:k} of vector model"
label var mul_pe_sc "{&Delta}{sub:k} of scalar model"
foreach i in mul_pe_ve var_lb_ve var_ub_ve{
	replace `i' = ln(`i')
}
foreach i in mul_pe_sc var_lb_sc var_ub_sc{
	replace `i' = ln(`i')
}
twoway (scatter mul_pe_ve level, sort lwidth(medthick) msize(small) cmissing(n)) ///
       (scatter mul_pe_sc level, sort lcolor(red) lwidth(medthick) msize(small) cmissing(n)) ///
       (rcap var_ub_ve var_lb_ve level, sort lcolor(green) lwidth(tiny) cmissing(n)) ///
       (rcap var_ub_sc var_lb_sc level, sort lcolor(red) lwidth(tiny) lpattern(dash) cmissing(n)), ///
	   xlabel(2 5 6 7 8 10 11 12, labsize(small)) xmtick(, labsize(small)) ///
       xtitle(Difficulty Level, size(small)) ytitle("{&Delta}{sub:k}", size(small)) ylabel(, labsize(small)) ///
       title("Log of Variances of Task Shocks ({&Delta}{sub:k}) by Level (Cognitive)", size(medium)) ///
       subtitle(Multiplicative Model with Skill Invariance, size(small)) ///
       legend(order(1 "{&Delta}{sub:k} of vector model" 2 "{&Delta}{sub:k} of scalar model" 3 "95% CI of vector model" 4 "95% CI of scalar model") row(2) size(small) nobox fcolor() ///
	   region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
       note("Note: The confidence interval is based on 1,000 iteration bootstrap." "Levels 1, 3, 4, 9 and 13 normalized to 1.", size(small) span)   ///
       graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
 	   saving("mul_logDelta_vesc", replace)
 	   graph export "mul_logDelta_vesc.pdf", replace	
restore	


**# cog_mul_wo_vesc
use "c_mul_wo_si_vesc", clear
capture destring var_lb_ve var_ub_ve var_lb_sc var_ub_sc, replace force

// replace var_ub_ = mul_pe + 1.96*var_sd_
// replace var_lb_ = mul_pe - 1.96*var_sd_

// replace var1 = subinstr(var1, "Level ", "", .)
// destring var1, replace
// rename level levelc2 
*kbar
preserve 
keep if var == "Kbar"
drop if level == 13
label var var_ub_ve "95% CI of vector model"
label var var_ub_sc "95% CI of scalar model"
label var mul_pe_ve "Minimum Skill Requirement of vector model"
label var mul_pe_sc "Minimum Skill Requirement of scalar model"
twoway (scatter mul_pe_ve level, sort lwidth(medthick) msize(small)) ///
       (scatter mul_pe_sc level, sort lcolor(red) lwidth(medthick) msize(small)) ///
       (rcap var_ub_ve var_lb_ve level, sort lcolor(green) lwidth(tiny)) ///
       (rcap var_ub_sc var_lb_sc level, sort lcolor(red) lwidth(tiny) lpattern(dash)), ///
       xlabel(2(1)12, labsize(small)) xmtick(, labsize(small)) ///
       xtitle(Difficulty Level, size(small)) ytitle(Kbar, size(small)) ylabel(, labsize(small)) ///
       title("Minimum Latent Cognitive Skills Requirement by Level", size(medium)) ///
       subtitle(Multiplicative Model without Skill Invariance, size(small)) ///
       legend(order(1 "Minimum Skill Requirement - vector" 2 "Minimum Skill Requirement - scalar" 3 "95% CI of vector model" 4 "95% CI of scalar model") row(2) size(small) nobox fcolor() ///
       region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
       note("Note: The confidence interval is based on 1,000 iteration bootstrap." "The Value at Level 13 is dropped in this figure due to the extreme variance in the estimation." "The value at Level 1 normalized to one.", size(small) span)   ///
       graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
       ylabel(, labsize(medium))
	   graph save "mul_kbar_wo_vesc", replace
       graph export "mul_kbar_wo_vesc.pdf", replace
restore	


preserve
keep if var == "Kbar"
label var mul_pe_ve "Minimum Skill Requirement of vector model"
label var mul_pe_sc "Minimum Skill Requirement of scalar model"
foreach i in mul_pe_ve var_lb_ve var_ub_ve{
	replace `i' = ln(`i')
}
foreach i in mul_pe_sc var_lb_sc var_ub_sc{
	replace `i' = ln(`i')
}
twoway (scatter mul_pe_ve level, sort lwidth(medthick) msize(small)) ///
       (scatter mul_pe_sc level, sort lcolor(red) lwidth(medthick) msize(small)) ///
       (rcap var_ub_ve var_lb_ve level, sort lcolor(green) lwidth(tiny)) ///
       (rcap var_ub_sc var_lb_sc level, sort lcolor(red) lwidth(tiny) lpattern(dash)), ///
       xlabel(2(1)12, labsize(small)) xmtick(, labsize(small)) ///
       xtitle(Difficulty Level, size(small)) ytitle(Kbar, size(small)) ylabel(, labsize(small)) ///
       title("Log of Minimum Latent Cognitive Skills Requirement by Level", size(medium)) ///
       subtitle(Multiplicative Model without Skill Invariance, size(small)) ///
       legend(order(1 "Minimum Skill Requirement - vector" 2 "Minimum Skill Requirement - scalar") row(2) size(small) nobox fcolor() ///
       region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
       note("Note: The confidence interval is based on 1,000 iteration bootstrap." "The Value at Level 13 is dropped in this figure due to the extreme variance in the estimation." "The value at Level 1 normalized to one.", size(small) span)   ///
       graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
       ylabel(, labsize(medium))
graph save "mul_logkbar_wo_vesc", replace
graph export "mul_logkbar_wo_vesc.pdf", replace
restore


preserve 
keep if var != "Kbar" & var != "Delta"& var != "Beta1"
label var var_ub_ve "95% CI of vector model"
label var var_ub_sc "95% CI of scalar model"
label var mul_pe_ve "σ²(ε,l) of vector model"
label var mul_pe_sc "σ²(ε,l) of scalar model"
// foreach i in mul_pe var_lb_ var_ub_{
// 	replace `i' = ln(`i')
// }
replace var_lb_ve = . if mul_pe_ve > 30
replace var_ub_ve = . if mul_pe_ve > 30
replace mul_pe_ve = . if mul_pe_ve > 30
replace var_lb_sc = . if mul_pe_sc > 30
replace var_ub_sc = . if mul_pe_sc > 30
replace mul_pe_sc = . if mul_pe_sc > 30

twoway (scatter mul_pe_ve level, sort lwidth(medthick) msize(small) cmissing(n)) ///
       (scatter mul_pe_sc level, sort lcolor(red) lwidth(medthick) msize(small) cmissing(n)) ///
       (rcap var_ub_ve var_lb_ve level, sort lcolor(green) lwidth(tiny) cmissing(n)) ///
       (rcap var_ub_sc var_lb_sc level, sort lcolor(red) lwidth(tiny) lpattern(dash) cmissing(n)), ///
	   xlabel(2(1)12, labsize(small)) xmtick(, labsize(small)) ///
       xtitle(Difficulty Level, size(small)) ytitle("σ²(ε,l)", size(small)) ylabel(, labsize(small)) ///
       title("Variances of Task Shocks (σ²(ε,l)) by Level (Cognitive)", size(medium)) ///
       subtitle(Multiplicative Model without Skill Invariance, size(small)) ///
       legend(order(1 "σ²(ε,l) of vector model" 2 "σ²(ε,l) of scalar model" 3 "95% CI of vector model" 4 "95% CI of scalar model") row(2) size(small) nobox fcolor() ///
	   region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
	   note("Note: The confidence interval is based on 1,000 iteration bootstrap." "The variances with values over 30 are dropped in the figure to better visualize the estimates" "and their confidence intervals are not shown." "Variances at level 1 and 13 are normalized to one.", size(small) span)   ///
       graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
       ylabel(, labsize(medium))
graph save "mul_sigma_wo_vesc", replace
graph export "mul_sigma_wo_vesc.pdf", replace
restore	
	   	

**log version
preserve 
keep if var != "Kbar" & var != "Delta"& var != "Beta1"
keep if var != "Kbar" & var != "Delta"& var != "Beta1"
label var var_ub_ve "95% CI of vector model"
label var var_ub_sc "95% CI of scalar model"
label var mul_pe_ve "σ²(ε,l) of vector model"
label var mul_pe_sc "σ²(ε,l) of scalar model"
foreach i in mul_pe_ve var_lb_ve var_ub_ve{
	replace `i' = ln(`i')
}
foreach i in mul_pe_sc var_lb_sc var_ub_sc{
	replace `i' = ln(`i')
}
// replace var_lb_ = . if mul_pe > 30
// replace var_ub_ = . if mul_pe > 30
// replace mul_pe = . if mul_pe > 30

twoway (scatter mul_pe_ve level, sort lwidth(medthick) msize(small) cmissing(n)) ///
       (scatter mul_pe_sc level, sort lcolor(red) lwidth(medthick) msize(small) cmissing(n)) ///
       (rcap var_ub_ve var_lb_ve level, sort lcolor(green) lwidth(tiny) cmissing(n)) ///
       (rcap var_ub_sc var_lb_sc level, sort lcolor(red) lwidth(tiny) lpattern(dash) cmissing(n)), ///
	   xlabel(2(1)12, labsize(small)) xmtick(, labsize(small)) ///
       xtitle(Difficulty Level, size(small)) ytitle("σ²(ε,l)", size(small)) ylabel(, labsize(small)) ///
	   xtitle(Difficulty Level, size(small)) ytitle("log(σ²(ε,l))", size(small)) ylabel(,labsize(small)) ///
       title("Log of Variances of Task Shocks (σ²(ε,l)) by Level (Cognitive)", size(medium)) ///
       subtitle(Multiplicative Model without Skill Invariance, size(small)) ///
       legend(order(1 "σ²(ε,l) of vector model" 2 "σ²(ε,l) of scalar model" 3 "95% CI of vector model" 4 "95% CI of scalar model") row(2) size(small) nobox fcolor() ///
       region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
	   note("Note: The confidence interval is based on 1,000 iteration bootstrap." "Log values are shown in the figure to better visualize values of all levels." "Variances at Level 1 and 13 are normalized to one.", size(small) span)   ///
	   graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
       ylabel(, labsize(medium))
	   graph save "mul_logsigma_wo_vesc", replace
       graph export "mul_logsigma_wo_vesc.pdf", replace
restore	

preserve 
keep if var == "Delta"
label var var_ub_ve "95% CI of vector model"
label var var_ub_sc "95% CI of scalar model"
label var mul_pe_ve "{&Delta}{sub:k} of vector model"
label var mul_pe_sc "{&Delta}{sub:k} of scalar model"
twoway (scatter mul_pe_ve level, sort lwidth(medthick) msize(small) cmissing(n)) ///
       (scatter mul_pe_sc level, sort lcolor(red) lwidth(medthick) msize(small) cmissing(n)) ///
       (rcap var_ub_ve var_lb_ve level, sort lcolor(green) lwidth(tiny) cmissing(n)) ///
       (rcap var_ub_sc var_lb_sc level, sort lcolor(red) lwidth(tiny) lpattern(dash) cmissing(n)), ///
	   xlabel(2 5 6 7 8 10 11 12, labsize(small)) xmtick(, labsize(small)) ///
       xtitle(Difficulty Level, size(small)) ytitle("{&Delta}{sub:k}", size(small)) ylabel(, labsize(small)) ///
       title("Variances of Task Shocks ({&Delta}{sub:k}) by Level (Cognitive)", size(medium)) ///
       subtitle(Multiplicative Model without Skill Invariance, size(small)) ///
       legend(order(1 "{&Delta}{sub:k} of vector model" 2 "{&Delta}{sub:k} of scalar model" 3 "95% CI of vector model" 4 "95% CI of scalar model") row(2) size(small) nobox fcolor() ///
	   region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
       note("Note: The confidence interval is based on 1,000 iteration bootstrap." "Levels 1, 3, 4, 9 and 13 normalized to 1.", size(small) span)   ///
       graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
 	   saving("mul_Delta_wo_vesc", replace)
 	   graph export "mul_Delta_wo_vesc.pdf", replace	
restore	

preserve 
keep if var == "Delta"
label var var_ub_ve "95% CI of vector model"
label var var_ub_sc "95% CI of scalar model"
label var mul_pe_ve "{&Delta}{sub:k} of vector model"
label var mul_pe_sc "{&Delta}{sub:k} of scalar model"
foreach i in mul_pe_ve var_lb_ve var_ub_ve{
	replace `i' = ln(`i')
}
foreach i in mul_pe_sc var_lb_sc var_ub_sc{
	replace `i' = ln(`i')
}
twoway (scatter mul_pe_ve level, sort lwidth(medthick) msize(small) cmissing(n)) ///
       (scatter mul_pe_sc level, sort lcolor(red) lwidth(medthick) msize(small) cmissing(n)) ///
       (rcap var_ub_ve var_lb_ve level, sort lcolor(green) lwidth(tiny) cmissing(n)) ///
       (rcap var_ub_sc var_lb_sc level, sort lcolor(red) lwidth(tiny) lpattern(dash) cmissing(n)), ///
	   xlabel(2 5 6 7 8 10 11 12, labsize(small)) xmtick(, labsize(small)) ///
       xtitle(Difficulty Level, size(small)) ytitle("{&Delta}{sub:k}", size(small)) ylabel(, labsize(small)) ///
       title("Log of Variances of Task Shocks ({&Delta}{sub:k}) by Level (Cognitive)", size(medium)) ///
       subtitle(Multiplicative Model without Skill Invariance, size(small)) ///
       legend(order(1 "{&Delta}{sub:k} of vector model" 2 "{&Delta}{sub:k} of scalar model" 3 "95% CI of vector model" 4 "95% CI of scalar model") row(2) size(small) nobox fcolor() ///
	   region(fcolor(white) margin(zero)) bmargin(zero) rowgap(tiny) colgap(tiny) keygap(tiny)) ///
       note("Note: The confidence interval is based on 1,000 iteration bootstrap." "Levels 1, 3, 4, 9 and 13 normalized to 1.", size(small) span)   ///
       graphregion(fcolor(white) ifcolor(white) ilwidth(vvvthin)) plotregion(margin(medsmall) lwidth(vvvthin) ilwidth(vvvthin)) ///
 	   saving("mul_logDelta_wo_vesc", replace)
 	   graph export "mul_logDelta_wo_vesc.pdf", replace	
restore	